package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemDictData;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 字典数据查询
 *
 * @author luwc
 * @title DictDataBO
 * @description
 * @time 2023/5/29 12:13:20
 * @version: 1.0
 */
@Data
public class DictDataBO extends AbstractPageQuery<SystemDictData> {
    private String label;
    private String status;
    private String marks;

    /**
     * 生成query conditions
     *
     * @return LambdaQueryWrapper<T>
     * @throws
     * @version 1.0.0
     * @author luwc
     * @time 2023/4/26 20:17:17
     */
    @Override
    public LambdaQueryWrapper<SystemDictData> toQueryWrapper() {
        LambdaQueryWrapper<SystemDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(label)) {
            lambdaQueryWrapper.like(SystemDictData::getLabel, label);
        }
        if (StringUtils.isNotEmpty(status)) {
            lambdaQueryWrapper.eq(SystemDictData::getStatus, status);
        }
        if (StringUtils.isNotEmpty(marks)) {
            lambdaQueryWrapper.eq(SystemDictData::getMarks, marks);
        }
        lambdaQueryWrapper.orderByDesc(SystemDictData::getId);
        return lambdaQueryWrapper;
    }
}
